import api from './config'

// 评分相关API接口
export const ratingApi = {
  // 对资源进行评分
  rateResource: (resourceId, rating) => {
    return api.post(`resources/${resourceId}/rating`, { rating })
  },

  // 更新评分
  updateRating: (resourceId, rating) => {
    return api.put(`resources/${resourceId}/rating`, { rating })
  },

  // 删除评分
  deleteRating: (resourceId) => {
    return api.delete(`resources/${resourceId}/rating`)
  },

  // 获取资源评分统计信息
  getRatingStats: (resourceId) => {
    return api.get(`resources/${resourceId}/rating/stats`)
  },

  // 获取用户对资源的评分
  getUserRating: (resourceId, userId = 1) => {
    return api.get(`resources/${resourceId}/rating/user/${userId}`)
  },

  // 获取资源的评分列表
  getResourceRatings: (resourceId, params = {}) => {
    return api.get(`resources/${resourceId}/ratings/list`, { params })
  },

  // 检查用户是否已对资源评分
  checkRatedStatus: (resourceId) => {
    return api.get(`resources/${resourceId}/rating/status`)
  },

  // 获取用户的评分列表
  getUserRatings: (params = {}) => {
    return api.get('ratings', { params })
  }
}

export default ratingApi 